home *** CD-ROM | disk | FTP | other *** search
- //***************************************************************************
- // OATH :: Object-oriented Abstract Type Hierarchy
- //***************************************************************************
- //
- // Copyright (C) 1991, 1990 Texas Instruments Incorporated
- // Permission is granted to any individual or institution
- // to use, copy, modify, and distribute this software,
- // provided that this complete copyright and permission notice
- // is maintained, intact, in all copies and supporting documentation.
- //
- // Texas Instruments Incorporated provides this software "as is"
- // without express or implied warranty.
- //
- //***************************************************************************
- // OATH obj export (exportP, importP, objRegisterP, oidP)
- //
- // History:
- // 07/91 Brian M Kennedy Original
- //
- //***************************************************************************
-
- #include "copyright.h"
-
- #include <oath/exportP.h>
-
- #include <iostream.h>
-
- #define OATH_EXPORT_FLAGS (ios::hex)
-
- /////////////////////////////////////////////////////////////////////////////
- // exportP Outlines
-
- exportP::
- exportP ()
- :LastOID(0), HashMask(0), Table(0), Stream(cout), StreamFlags(0)
- {ensure(0, "This shouldn't be called!");}
-
- exportP::
- exportP (const exportP&)
- :LastOID(0), HashMask(0), Table(0), Stream(cout), StreamFlags(0)
- {ensure(0, "This shouldn't be called!");}
-
- exportP::
- exportP (ostream& S, unsigned int HashKey)
- :LastOID(0), HashMask((1UL << HashKey) - 1),
- Table(new objRegisterP* [HashMask + 1]),
- Stream(S), StreamFlags(Stream.flags(OATH_EXPORT_FLAGS))
- {Stream.width(0);
- for(unsigned int I = 0; I <= HashMask; ++I)
- Table[I] = 0;
- }
-
- exportP::
- ~exportP ()
- {Stream.flags(StreamFlags);}
-
- int exportP::
- registerObj (const oathCoreG* O, oidP& I)
- {unsigned long Hash = HashMask & ((unsigned long)O >> 3);
- I = (Table[Hash] ? Table[Hash]->oid(O) : oidP(0));
- if(I)
- return 1;
- else
- {I = ++LastOID;
- Table[Hash] = new objRegisterP (O, I, Table[Hash]);
- return 0;
- }
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // importP Outlines
-
- importP::
- importP ()
- :HashMask(0), Table(0), Stream(cin), StreamFlags(0)
- {ensure(0, "This shouldn't be called!");}
-
- importP::
- importP (const importP&)
- :HashMask(0), Table(0), Stream(cin), StreamFlags(0)
- {ensure(0, "This shouldn't be called!");}
-
- importP::
- importP (istream& S, unsigned int HashKey)
- :HashMask((1UL << HashKey) - 1),
- Table(new objRegisterP* [HashMask + 1]),
- Stream(S), StreamFlags(Stream.flags(OATH_EXPORT_FLAGS))
- {Stream.width(0);
- for(unsigned int I = 0; I <= HashMask; ++I)
- Table[I] = 0;
- }
-
- importP::
- ~importP ()
- {Stream.flags(StreamFlags);}
-
-
- //***************************************************************************
-